package com.fenghuajueli.libbasecoreui.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.fenghuajueli.libbasecoreui.utils.ImageLoadManager;

public class CommonBaseViewHolder {

    private View inflate;
    private Context mContext;

    public View getView() {
        return inflate;
    }

    public Context getmContext() {
        return mContext;
    }

    public CommonBaseViewHolder(View itemView, Context context) {
        this.inflate = itemView;
        this.mContext = context;
    }

    /*设置ImageView 控件*/
    public void setImageResource(int ivID, int resouceId) {
        ImageView img = inflate.findViewById(ivID);
        img.setImageResource(resouceId);
    }


    public void loadImage(int viewId, String path) {
        ImageView img = inflate.findViewById(viewId);
        ImageLoadManager.loadForImageView(img, path);

    }

    public void setViewStatus(int viewId, int visibility) {
        View view = inflate.findViewById(viewId);
        view.setVisibility(visibility);
    }

    public void setText(int viewId, String text){
        TextView textView = inflate.findViewById(viewId);
        textView.setText(text);
    }

    public void setOnClickListener(int viewId, View.OnClickListener onClickListener){
        View view = inflate.findViewById(viewId);
        view.setOnClickListener(onClickListener);
    }
}
